#pragma once

#include "../can_adapter.h"
#include "../can_transreceiver.h"
#include "../ziyan/b30_001.h"
namespace sensor::radar {

class NezhaCanAdapter : public CanAdapter {
public:
    explicit NezhaCanAdapter(std::unordered_map<std::string, std::shared_ptr<CanTransreceiver>> devs);

    virtual void onReceiveCanMessage(const std::string& dev, int fid, muduo::net::Buffer& buffer) override;
    virtual void onReceiveGnssMessage(const interface::msg::Gnss::SharedPtr msg) override;
    virtual void onReceiveInformationMessage(const interface::msg::CarInformation msg) override;

private:
    void onReceiveEP30291Info(const std::string&, int fid, muduo::net::Buffer& buffer);
    void onReceiveEP30223Info(const std::string&, int fid, muduo::net::Buffer& buffer);
    void onReceiveEP3027BInfo(const std::string&, int fid, muduo::net::Buffer& buffer);
    void onReceiveEP302FFInfo(const std::string&, int fid, muduo::net::Buffer& buffer);

private:
    using CanMessageUnpackFunction = std::function<void(const std::string& dev, int fid, muduo::net::Buffer& buffer)>;
    std::map<int, CanMessageUnpackFunction> message_unpack_table_;
    interface::msg::CarInformation car_information_;
};

}